/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAOHibernate;

import DAO.AlunoDAO;
import entidade.Aluno;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;

/**
 *
 * @author Thais
 */
public class AlunoDAOHibernate implements AlunoDAO {

    @Override
    public List<Aluno> buscarPorNome(String nome) {
       EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProjetoFinalClientePU");
       EntityManager em = emf.createEntityManager();
       Query buscar = em.createQuery("Select object(c) from Aluno as c where c.nome LIKE ?1");
       buscar.setParameter(1, '%' + nome + '%');
       return buscar.getResultList();      
    }
}

